package com.ff.miaosha.controller;

import com.ff.miaosha.redis.RedisService;
import com.ff.miaosha.redis.UserKey;
import com.ff.miaosha.result.CodeMsg;
import com.ff.miaosha.result.Result;
import com.ff.miaosha.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

    @Autowired
    RedisService redisService;

    @ResponseBody
    @RequestMapping("hello123")
    public String hello(@Validated LoginVo vo){
        return "hee";
    }

    @ResponseBody
    @RequestMapping("helloError")
    public Result<String> helloError(){
        return Result.error(CodeMsg.SERVER_ERROR);
    }

    @ResponseBody
    @RequestMapping("add")
    public Result<String> redisIncr(){
        redisService.set(UserKey.getById,"user","12efafraf");
        return Result.success("ok");
    }
}
